{% extends "base.html" %}

{% block content %}
<label for="autocomplete">Ingrese el nombre o la cedula del usuario:</label>
<input type="text" name="user" id="autocomplete"/>
{% end %}

{% block scripts %}
<link rel="stylesheet" href="/static/css/autocomplete.css" type="text/css">
<script type="text/javascript">
$('#autocomplete').autocomplete({
    serviceUrl: '/users/filter',
	paramName: 'query',
    onSelect: function (suggestion){
		$.ajax({
			type: "POST",
			url: '/users/name',
			data: {user: suggestion.data, name: suggestion.value},
			success: function(){window.location.href = "{{dst}}";},
			dataType: 'text'
		});
    }
});
</script>
{% end %}
